package com.java.thread.lock;

import java.util.Random;

public class ReadWriteLockTest {
    public static void main(String[] args) {
        final TheData myData = new TheData();  //这是各线程的共享数据
        for(int i=0;i<3;i++){ //开启3个读线程
            new Thread(new Runnable(){
                @Override
                public void run() {
                    while(true){
                        myData.get();
                    }
                }
            }).start();
        }
        for(int i=0;i<3;i++){ //开启3个写线程
            new Thread(new Runnable(){
                @Override
                public void run() {
                    while(true){
                        myData.put(new Random().nextInt(10000));
                    }
                }
            }).start();
        }
    }
}

